from translate import Translator


def translate_text(text, from_lang, to_lang):
    # 安装
    # pip install translate
    result_text = Translator(from_lang=from_lang, to_lang=to_lang).translate(text)
    return result_text


def translate_zn_to_en(text):
    translate_text = Translator(from_lang="ZH", to_lang="EN").translate(text)
    return translate_text


def translate_test():
    print(Translator(from_lang="ZH", to_lang="EN").translate('我是通义灵码，你的智能编码助手'))
    print(Translator(from_lang="ZH", to_lang="EN").translate("I'm Tongyi Lingyi, your intelligent coding assistant"))
    print(Translator(from_lang="ZH", to_lang="EN-US").translate('我是通义灵码，你的智能编码助手'))

    print(Translator(from_lang="ZH", to_lang="JA").translate('我是通义灵码，你的智能编码助手'))
    print(Translator(from_lang="JA", to_lang="ZH").translate('こんにちは、朝食は食べましたか？'))
    print(Translator(from_lang="ZH", to_lang="JA").translate('你好，吃早饭了吗'))

if __name__ == '__main__':
    translate_test()